package com.fengye.algorithms.leecode;

/**
 * @Author fengye
 * @Date 2023/4/8 9:38
 **/
public class LengthOfLongestSubstring03 {
    public int lengthOfLongestSubstring(String s) {
        if(s.length() == 0) {
            return 0;
        }
        if(s.length()==1) {
            return 1;
        }

        int num = 1;
        for(int i=0;i<s.length();i++) {
            for(int j=i+1;j<s.length();j++) {
                String sub = s.substring(i, j);
                char c = s.charAt(j);
                if(!sub.contains(Character.toString(c))) {
                    num = Math.max(num, j-i+1);
                } else {
                    break;
                }
            }
        }

        return num;
    }
}
